package com.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.model.auto.*;
import com.example.service.ICommentInfoService;
import com.example.service.INewsInfoService;
import com.example.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * <p>
 * 评论信息表 前端控制器
 * </p>
 *
 * @author 姚帅
 * @since 2023-02-19
 */
@RestController
@RequestMapping("/comment")
public class CommentInfoController {

    @Autowired
    private ICommentInfoService iCommentInfoService;


    /*添加评论*/
    @PostMapping("/setCom")
    public void setFeedback(@RequestBody CommentInfo commentInfo){
        System.out.println(commentInfo);
        iCommentInfoService.save(commentInfo);
    }
    /*查询评论*/
    @GetMapping("/getcom/{id}")
    public List<CommentAccount> getCom(@PathVariable("id") int id){
        return iCommentInfoService.SelectComById(id);
    }

    /*根据用户id查询评论 */
    @GetMapping("/getUserCom/{id}")
    public List<UserCommentIAccount> getUserCom(@PathVariable("id") int id){
        return iCommentInfoService.FdComById(id);
    }
    @PostMapping("/deletedById/{id}")
    public boolean deleted(@PathVariable("id") int id){
        return iCommentInfoService.removeById(id);
    }


}
